package com.example.permission.dao;

import com.example.permission.entity.Role;
import com.example.permission.entity.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 角色持久接口
 */
public interface RoleMapper extends BaseMapper<Role>{

    //通过角色id查找权限id
    @Select("select permission_id from role_permission where role_id = #{roleId}")
    List<Integer> getPermissionIdsByRoleId(Integer userId);

    //添加权限
    @Insert("insert into role_permission(role_id,permission_id) value(#{roleId},#{permissionId})")
    Integer addPermissionIdByRoleId(Integer roleId,Integer permissionId );

    //删除权限
    @Delete("delete from role_permission where permission_id = #{permissionId}")
    Integer removePermissionIdByRoleId(Integer id, Integer permissionId);
}
